Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tree-to-string

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree-to-string

Convert a tree structure into a human friendly string

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

tree-to-string

npm install tree-to-string

Usage

const treeToString = require('tree-to-string')

const tree = {
  value: [7],
  children: [{
    value: [3, 5],
    children: [{
      value: [2]
    }, {
      value: [4]
    }, {
      value: [6]
    }]
  }, {
    value: [8]
  }]
}

console.log(treeToString(tree))

Running the above prints something similar to

[ 2 ]─┐
      │
[ 4 ]─┼─[ 3, 5 ]─┐
      │          │
[ 6 ]─┘          ├─[ 7 ]
                 │
           [ 8 ]─┘

API

const str = treeToString(tree, [format])

Converts a tree to a human friendly string. The tree should have a layout similar to this

{
  value: someJsObject,
  children: [tree, ...]
}

Format defaults to util.inspect. Change this to your own method that pretty prints your object if your prefer.

License

MIT

FAQs

Package last updated on 21 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc